package com.hzsai.mininote.controller;

import com.hzsai.mininote.common.ResponseRe;
import com.hzsai.mininote.entity.User;
import com.hzsai.mininote.entity.UserVO;
import com.hzsai.mininote.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author hzsai
 * @date 2020/1/8 23:28
 * @usage:
 */
@Api(tags = "用户管理")
@RestController
public class UserController {

    @Autowired
    UserService userService;

    @ApiOperation(value = "添加用户")
    @PostMapping("/user")
    public ResponseRe addUser(@RequestBody @Valid UserVO userVO) {
        return userService.add(userVO);
    }

    public ResponseRe updateUser(@RequestBody @Valid User user) {
        return userService.update(user);
    }
}
